from django.http import JsonResponse
from django.shortcuts import render

# Create your views here.
from rest_framework.views import APIView
from django.core.handlers.wsgi import WSGIHandler

from mainapp.models import Store, SubCategory


class Sorder(APIView):
    def get(self,request,*args,**kwargs):
        name = request.GET.get('name')
        store = Store.objects.filter(name=name).first()
        subs = SubCategory.objects.all()
        data ={
            'store':store,
            'sub_list': subs,
        }

        return JsonResponse({'code':200,'msg':'','data':data})
class Scomment(APIView):
    def get(self,request,*args,**kwargs):
        name = request.GET.get('name')
        store = Store.objects.filter(name=name).first()
        return JsonResponse({'code': 200, 'msg': ''})

class Self(APIView):
    def get(self,request,*args,**kwargs):
        name = request.GET.get('name')
        store = Store.objects.filter(name=name).first()
        return JsonResponse({'code': 200, 'msg': '', 'data': store})


class Category(APIView):
    pass


class ShopCar(APIView):
    pass